<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>transition</title>
    <style>
      #main {
        width: 100px;
        height: 100px;
        background-color: red;
        transition: all 0.3s ease;
      }

      #main:hover {
        width: 200px;
        height: 200px;
        background-color: blueviolet;
      }

      #main.larger {
        width: 900px;
        height: 800px;
      }
    </style>
  </head>
  <body>
    <button id="change">点我</button>
    <div id="main"></div>
    <script>
      const change = document.getElementById("change");
      const div = document.getElementById("main");
      change.addEventListener("click", () => {
        div.classList.toggle("larger");
      });
    </script>
  </body>
</html>
